<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>动画</title>
    <style>
        section{
            width: 1000px;
            height: 500px;
            border: 2px solid black;
            position: relative;
        }
        div{
            width: 200px;
            height: 200px;
            background-color: rebeccapurple;
            position: absolute;

            
            animation-name: move;
            animation-duration: 2s;
            animation-timing-function: linear;
            animation-delay: 1s;
            /*iteration:迭代，重复;infinite:无数次*/
            animation-iteration-count: infinite; 
            /*动画填充模式*/
            /*
              backwards:让元素回到动画开始前的状态；
              forwards：让元素停留在动画结束时的状态；
              both：动画开始前，元素处于动画开始状态，
              动画结束时，元素处于动画结束状态。
            */
            animation-fill-mode: both;

            animation: move 2s forwards linear infinite,changeColor 3s infinite;
        }

        /*(1)定义动画，描述动画过程*/
        /*关键帧动画*/
        @keyframes move{
            0%{
                top: 0px;
                left: 0px;
            }
            60%{
                top: 0px;
                /*right: 0px;*/
                left: 800px;
            }
            100%{
                /*bottom: 0px;
                right: 0px;*/
                top: 300px;
                left: 800px;
            }
        }

        @keyframes changeColor{
            0%{
                background-color: rebeccapurple;
            }
            20%{
                background-color: red;
            }
            40%{
                background-color: blue;
            }
            60%{
                background-color: yellow;
            }
            100%{
                background-color: pink;
            }
        }


    </style>
</head>
<body>
    <section>
        <div></div>
    </section>
    
</body>
</html>